﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NetTaste;
using VM.Common.EntityEnum;
using VM.Common.Result;
using VM.Entity.EntityMap.System.Code;
using VM.IBLL.Common;
using VM.IBLL.System.Code;
using VM.WebCore.Jwt;
using VM.WebCore.SwaggerExtend;
using VM.Wechat;

namespace VM.WebAPI.Controllers
{
    /// <summary>
    /// 通用接口
    /// </summary>
    [Route("api/common")]
    [ApiController]
    public class CommonController : ControllerBase
    {
        private readonly ICommonBLL _ICommonBLL;
        private readonly IJWTService _IJWTService;
        private readonly IHttpContextAccessor _HttpContextAccessor;

        public CommonController(IJWTService iJWTService, ICommonBLL iCommonBLL, IHttpContextAccessor httpContextAccessor)
        {

            _ICommonBLL = iCommonBLL;
            _IJWTService = iJWTService;
            _HttpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 通用删除某条数据接口，单个表，   PC+PHONE
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Authorize]//要求通过授权才行---只要能鉴权成功，都能通过]
        [Route("commonDelById")]
        [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
        public ApiResult commonDelById(int menuId,int id,int billStatus=999)
        {
            //解析Jwt,获取到UserId
            int UserId = _IJWTService.GetUserIdByAuthInfoStr();

            //校验验证码是否可用，如果可用，返回true
            ApiResult Res = _ICommonBLL.commonDelById(UserId,menuId,id,billStatus);
            return Res;
        }





    }
}
